﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace SnapShot
{
    public partial class frmTFS : Form
    {
        public SnapShot.ConfiguracaoTFS ConfigTFS { get; set; }

        public frmTFS()
        {
            InitializeComponent();
            ConfigTFS = new SnapShot.ConfiguracaoTFS();
        }

        private void frmTFS_Load(object sender, EventArgs e)
        {
            cmdProjeto.DataSource = TFS.Projeto.Store.Projects;
            cmdProjeto.ValueMember = "Name";
            cmdProjeto.Update();

            chkUsarTFS.Checked = ConfigTFS.UsarTFS;
            txtServidor.Text = ConfigTFS.Servidor;
            txtSituacoes.Text = ConfigTFS.FiltroEstado;
            if (!String.IsNullOrEmpty(ConfigTFS.ProjetoPadrao))
                cmdProjeto.SelectedItem = TFS.Projeto.Store.Projects[ConfigTFS.ProjetoPadrao];
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            ConfigTFS.UsarTFS = chkUsarTFS.Checked;
            ConfigTFS.Servidor = txtServidor.Text;
            ConfigTFS.ProjetoPadrao = (cmdProjeto.SelectedItem as Project).Name;
            ConfigTFS.FiltroEstado = txtSituacoes.Text;
            TFS.RefazerLogon();
            this.Close();
        }
    }
}
